home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 1437 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.3 KB  |  46 lines

  1. Path: news.cs.hope.edu!vnopstal
  2. From: vnopstal@cs.hope.edu (Michael Van Opstall)
  3. Newsgroups: comp.lang.c++
  4. Subject: [Q] Overloading >>
  5. Date: 10 Jan 1996 22:38:18 GMT
  6. Organization: Hope College
  7. Message-ID: <4d1f4q$7oj@news.cs.hope.edu>
  8. NNTP-Posting-Host: smaug.cs.hope.edu
  9. X-Newsreader: TIN [version 1.2 PL2]
  10.  
  11. I was actually pretty clear on output stream overloading, but I really have
  12. a question on overloading the >> operator. I really just need the function
  13. header and param list. Right now, I'm using this:
  14.  
  15. istream& operator>>(istream& in, typename t1)
  16.  
  17. which compiles, but I don't understand what stream is which, nor what to
  18. do with t1. Am I supposed to do something like
  19.  
  20. in >> whatever >> I >> want;
  21. t1.fpart=whatever;
  22. t1.mpart=I;
  23. t1.lpart=want;
  24. return in;
  25.  
  26. or what? Why do I need to return an istream&? Same reason the = op requires
  27. a return?
  28.  
  29. I'd love to be able to do a istream::Get and then parse the string and put
  30. it where it belongs in the object. That's why I'm concerned about returning
  31. a stream. This is ideally what I want. Is it kosher?
  32.  
  33. char* input;
  34. in.Get(input, 80);    // I know this isn't perfect syntax for Get...
  35.  
  36. // ...parsing removed...//
  37. t1.fpart= ...something I got during parsing...
  38. etc.
  39. return in;
  40.  
  41. Thanks in Advance for help
  42.  
  43. --
  44. Michael A. Van Opstall  --  vnopstal@cs.hope.edu
  45. http://www.cs.hope.edu/~vnopstal/deal.html - try it
  46.